package org.dairy.farms.model;

import org.dairy.farms.interceptor.hibernate.Auditable;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * Created by IntelliJ IDEA.
 * User: gduggira
 * Date: Jul 12, 2011
 * Time: 4:54:44 PM
 */
@javax.persistence.Table(name = "REVENUE_TYPE")
@Entity
public class RevenueType implements Auditable {
    public static final String LACTATION_REVENUE = "LACTATION_REVENUE";
    public static final String FARM_MISC_REVENUE = "FARM_MISC_REVENUE";
    public static final String LIVESTOCK_SALE_REVENUE = "LIVESTOCK_SALE_REVENUE";
    public static final String LIVESTOCK_MISC_REVENUE = "LIVESTOCK_MISC_REVENUE";
    public static final String FARM_MANURE_REVENUE = "FARM_MANURE_REVENUE";

    public static final String LIVESTOCK_REVENUE = "LIVESTOCK_REVENUE";
    public static final String FARM_REVENUE = "FARM_REVENUE";

    @javax.persistence.Column(name = "ID")
    @Id
    @GeneratedValue
    private Long id;

    @javax.persistence.Column(name = "NAME")
    private String name;

    @javax.persistence.Column(name = "DESCRIPTION")
    private String description;

    @Column(name = "REVENUE_TYPE_OF")
    private String revenueTypeOf;

    @OneToMany(mappedBy = "revenueType", targetEntity = Revenue.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private Set<Revenue> revenues = new HashSet<Revenue>();

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Set<Revenue> getRevenues() {
        return revenues;
    }

    public void setRevenues(Set<Revenue> revenues) {
        this.revenues = revenues;
    }

    public String getRevenueTypeOf() {
        return revenueTypeOf;
    }

    public void setRevenueTypeOf(String revenueTypeOf) {
        this.revenueTypeOf = revenueTypeOf;
    }

    @Embedded
    private AuditInfo auditInfo = new AuditInfo();

    public AuditInfo getAuditInfo() {
        return auditInfo;
    }

    public void setAuditInfo(AuditInfo auditInfo) {
        this.auditInfo = auditInfo;
    }
}
